home *** CD-ROM | disk | FTP | other *** search
- Path: news.intelenet.com!usenet
- From: james@superstore.com
- Newsgroups: comp.lang.c
- Subject: Re: Pointer-to-Double as Function Arg
- Date: Wed, 17 Jan 1996 10:17:27 GMT
- Organization: InteleNet Communications, Inc.
- Message-ID: <4dijbu$rau@nikita.intelenet.net>
- References: <4dfccl$j5h@colossus.holonet.net>
- NNTP-Posting-Host: 205.162.86.156
- X-Newsreader: Forte Free Agent 1.0.82
-
- mitch@news.mdli.com (Mitch Miller) wrote:
-
- >I'm having a problem with a function that takes a
- >couple of pointer-to-double arguments, initializes then
- >and assigns values to them in an array style:
-
- >Function is something like:
-
- > int GetValue( long iDim, double * Values1, double *
- > Values2 )
- > {
- > int iter;
- try
- *Values1 = (double *) malloc( iDim * sizeof( double ));
- > if (Values1 == NULL )
- >
- and ....
- *Values2 = (double *) malloc( iDim * sizeof( double ));
- > if (Values2 == NULL )
- > ...
-
- > for (iter=1; iter<iDim; iter++)
- > {
- > Values1[iter] = ...;
- > Values2[iter] = ...;
-
- > }
-
- > return 1;
- > }
-
- >Call from main:
-
- > double * Ptr1;
- > double * Ptr2;
-
- > if (!GetValue( iSize, &Ptr1, &Ptr2 ) )....
-
-
- >When I look at the values of Values1 and Values2 in GetValue, they have
- >the correct values.
-
- >However, back in main, they have NULL values.
-
- >If I make Ptr1 and Ptr2 global variables so that they are not included
- >in the function calls, the code works fine.
-
- >I've checked the FAQs, but couldn't find anything quite like this.
-
- >Thanks in advance...
-
-
-